'''
去重
'''
class Solution:
    def MLS(self , arr ):
        # write code here
        nums = set(arr)
        max = 0
        for x in nums:
            if x-1 not in nums:
                y = x + 1
                while y in nums:
                    y = y + 1
                if (y-x) > max:
                    max = y-x
        return max
'''
排序并去重
'''
class Solution:
    def MLS(self , arr ):
        # write code here
        arr = sorted(set(arr))
        n = len(arr)
        dp = [1 for _ in range(n)]
        for i in range(1, n):
            if arr[i] - arr[i - 1] == 1:
                dp[i] = dp[i - 1] + 1
        return max(dp)